﻿# 指定cmake版本
cmake_minimum_required(VERSION 3.15.0)

# 工程名称
project(mqtt_client)

# 添加预定义宏 
MESSAGE(INFO "--------------------------------")
MESSAGE(STATUS "CMAKE_CURRENT_SOURCE_DIR : ${CMAKE_CURRENT_SOURCE_DIR}")
MESSAGE(STATUS "option for log : ${ENABLE_LOG_PRINTF}")

# 移除警告信息
add_definitions(-w)

# 遍历头文件
file(GLOB_RECURSE headerFiles "${PROJECT_SOURCE_DIR}/*.hpp" "${PROJECT_SOURCE_DIR}/*.h")
# 遍历源文件
file(GLOB_RECURSE srcFiles "${PROJECT_SOURCE_DIR}/*.cpp" "${PROJECT_SOURCE_DIR}/*.c")

# 输出遍历文件信息
MESSAGE(STATUS "Build headerFiles: ${headerFiles}")
MESSAGE(STATUS "Build srcFiles: ${srcFiles}")

# 添加编译文件
add_executable(${PROJECT_NAME}
	${headerFiles}
	${srcFiles}
	)

IF(DEFINED TPROJECT_VERSION)
	MESSAGE(STATUS " TPROJECT_VERSION: ${TPROJECT_VERSION}")
	SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES VERSION ${TPROJECT_VERSION} SOVERSION 1 )
ENDIF()

# 链接库文件
target_link_libraries(${PROJECT_NAME}
PUBLIC 
	#${JSONCPP_LIBS}
	#${OPENSSL_LIBS}
	#${CURL_LIBS}
	#${libcryptopp_LIBS}
	#${PAHO_MQTTC_LIBS}
	#${libftmqttcore_LIBS}
	ftmqtt_core_static
	)

# 加载依赖库
target_link_directories(${PROJECT_NAME}
PUBLIC 
	#${JSONCPP_LIBRARY_DIR}
	#${OPENSSL_LIBRARY_DIR}
	#${CURL_LIBRARY_DIR}
	#${libcryptopp_LIBRARY_DIR}
	#${libftmqttcore_LIBRARY_DIR}
	#${PAHO_MQTTC_INCLUDE_DIR}
 )	
# 加载源文件
# 加载库依赖头
target_include_directories(${PROJECT_NAME}
PUBLIC 
	${PROJECT_SOURCE_DIR}
	#${libftmqttcore_INCLUDE_DIR}
	${PROJECT_ROOT}/tests/mvMqttCore
	#${JSONCPP_INCLUDE_DIR}
	#${OPENSSL_INCLUDE_DIR}
	#${CURL_INCLUDE_DIR}
	#${libcryptopp_INCLUDE_DIR}
	#${PAHO_MQTTC_LIBRARY_DIR}
	)
# 安装头文件
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    DESTINATION ${CMAKE_INSTALL_PREFIX}/include
    FILES_MATCHING
    PATTERN "*.h"
    PATTERN "*.hpp" 
	PATTERN "CMakeLists.txt" EXCLUDE
    )
# 安装文件
INSTALL(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
    LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
    RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
# 安装配置文件
#install(FILES ${PROJECT_ROOT}/conf/dbus/upserver.conf
#	#DESTINATION /usr/share/dbus-1/system.d
#	DESTINATION ${CMAKE_INSTALL_PREFIX})



